package com.century.sjt.activity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;

import com.century.sjt.EMChat.domain.EaseEmojicon;

import com.century.sjt.EMChat.widget.EaseChatInputMenu;
import com.century.sjt.EMChat.widget.EaseVoiceRecorderView;
import com.century.sjt.R;
import com.century.sjt.widget.SpeechInputMenu;
import com.century.sjt.widget.TitleBar.SjtTitleBar;

/**
 * Created by asus on 2016/9/23.
 * 语音翻译
 */

public class SpeechTranslationActivity extends BaseActivity{
    private SjtTitleBar titleBar;
    protected SpeechInputMenu inputMenu_1;
    protected SpeechInputMenu inputMenu_2;
    protected EaseVoiceRecorderView voiceRecorderView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_speechtranslation);
        initView();
        initEvent();
    }
    @Override
    protected void initView(){

        titleBar = (SjtTitleBar) findViewById(R.id.title_bar);
        //       标题栏
        titleBar.setTitle(getResources().getString(R.string.tab_merchants_shop_bank));
        titleBar.setLeftIconResource(getResources().getString(R.string.icon_return));
        titleBar.setLeftLayoutClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        // 按住说话录音控件
        voiceRecorderView = (EaseVoiceRecorderView) findViewById(R.id.voice_recorder);
        inputMenu_1 = (SpeechInputMenu) findViewById(R.id.input_menu_1);
        inputMenu_2 = (SpeechInputMenu) findViewById(R.id.input_menu_2);
        // init input menu
        inputMenu_1.init(null);
        inputMenu_2.init(null);
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void initEvent() {
        inputMenu_1.setSpeechInputMenuListener(new SpeechInputMenu.SpeechInputMenuListener() {

            @Override
            public void onSendMessage(String content) {
                // 发送文本消息


            }

            @Override
            public boolean onPressToSpeakBtnTouch(View v, MotionEvent event) {
                return voiceRecorderView.onPressToSpeakBtnTouch(v, event, new EaseVoiceRecorderView.EaseVoiceRecorderCallback() {

                    @Override
                    public void onVoiceRecordComplete(String voiceFilePath, int voiceTimeLength) {
                        // 发送语音消息
//                        sendVoiceMessage(voiceFilePath, voiceTimeLength);
                    }
                });
            }

            @Override
            public void onBigExpressionClicked(EaseEmojicon emojicon) {
                //发送大表情(动态表情)
            }
            @Override
            public void onTextChanged(String content) {
                // 文本变化监听

            }
        });
        inputMenu_2.setSpeechInputMenuListener(new SpeechInputMenu.SpeechInputMenuListener() {

            @Override
            public void onSendMessage(String content) {
                // 发送文本消息


            }

            @Override
            public boolean onPressToSpeakBtnTouch(View v, MotionEvent event) {
                return voiceRecorderView.onPressToSpeakBtnTouch(v, event, new EaseVoiceRecorderView.EaseVoiceRecorderCallback() {

                    @Override
                    public void onVoiceRecordComplete(String voiceFilePath, int voiceTimeLength) {
                        // 发送语音消息
//                        sendVoiceMessage(voiceFilePath, voiceTimeLength);
                    }
                });
            }

            @Override
            public void onBigExpressionClicked(EaseEmojicon emojicon) {
                //发送大表情(动态表情)
            }
            @Override
            public void onTextChanged(String content) {
                // 文本变化监听

            }
        });
    }

    @Override
    protected void initData() {

    }
}
